package com.tcwlkj.uuService.adapter;

import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.tcwlkj.uuService.R;
import com.tcwlkj.uuService.model.OrderModel;

import java.util.ArrayList;

/**
 * Created by Administrator on 2017/10/31 0031.
 */

public class FinishOrderAdapter extends RecyclerView.Adapter<FinishOrderAdapter.ViewHolder> {

    private ArrayList<OrderModel> mMsgList;

    public FinishOrderAdapter(ArrayList<OrderModel> mMsgList){
        this.mMsgList=mMsgList;
    }

    public void updateData(ArrayList<OrderModel> data) {
        this.mMsgList = data;
        notifyDataSetChanged();
    }
    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = View.inflate(parent.getContext(), R.layout.item_finish_order, null);
        return new FinishOrderAdapter.ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {
        holder.item_finish_time.setText(mMsgList.get(position).getFinishTime());
        switch (mMsgList.get(position).getSendType()){
            case "10":
                holder.order_type.setText("同城送");
                break;
            case "20":
                holder.order_type.setText("同城取");
                break;
            case "30":
                holder.order_type.setText("同城买");
                break;
            case "40":
                holder.order_type.setText("同城帮");
                break;
            case "50":
                holder.order_type.setText("同城排");
                break;
        }
        holder.ding_dan_num.setText(mMsgList.get(position).getOrderCode());
        //holder.ding_dan_num.setText("O"+mMsgList.get(position).getID()+"-"+mMsgList.get(position).getCode());
        holder.order_shouru.setText(mMsgList.get(position).getDriverFreightMoney());
        holder.song_juli.setText(mMsgList.get(position).getDistance());
        holder.yong_shijian.setText(mMsgList.get(position).getTotalTimeSpan());
    }

    @Override
    public int getItemCount() {
        return mMsgList.size();
    }
    public static class ViewHolder extends RecyclerView.ViewHolder{
        TextView item_finish_time;
        TextView order_type;
        TextView ding_dan_num;
        TextView order_shouru;
        TextView song_juli;
        TextView yong_shijian;
        public ViewHolder(View itemView) {
            super(itemView);
            item_finish_time= (TextView) itemView.findViewById(R.id.item_finish_time);
            order_type= (TextView) itemView.findViewById(R.id.order_type);
            ding_dan_num= (TextView) itemView.findViewById(R.id.ding_dan_num);
            order_shouru= (TextView) itemView.findViewById(R.id.order_shouru);
            song_juli= (TextView) itemView.findViewById(R.id.song_juli);
            yong_shijian= (TextView) itemView.findViewById(R.id.yong_shijian);
        }

    }

}
